'''
Created on Sep 19, 2011

@author: oabalbin
'''
from collections import defaultdict,deque

def read_positions(ifile):
    '''
    '''
    keys,values=deque(),deque()
    ifile = open(ifile)
    for l in ifile:
        if l.startswith('#'):
            continue
        fields=l.strip('\n').split(',')
    
    for f in fields:
        k,v = f.split('|')[0],f.split('|')[1:]
        keys.append(k),values.append(v)
        
    ifile.close()
    return fields, keys,values



def isec_arrays(filea,fileb):
    '''
    '''
    m1=set(read_positions(filea))
    m2=set(read_positions(fileb))
    #print sys.getsizeof(m1), sys.getsizeof(m2)
    isec=m1.intersection(m2)        
    return isec


ifile='/exds/projects/alignment_indexes/gatk/hg19/dbSNP/dbSNP132_12_03_10_00-All_processed_04_05_11_3_db132.pos.base'
ff, mm = read_positions(ifile)
